//**************************************************************************
//      Account1.java            Author:GK
//
//      允许仅使用账户名和账号建立账户，并假设初始余额为0。
//**************************************************************************

import java.text.Normalizer;
import java.text.NumberFormat;

public class Account1 {
    private final double RATE = 0.035;  // interest rate of 3.5%
    private long acctNumber;
    private double balance;
    private String name;

    //----------------------------------------------------------------------
    //  Sets up the account by defining its owner, account number,
    //  and initial balance.
    //----------------------------------------------------------------------
    public Account1(String owner, long account, double initial)
    {
        name = owner;
        acctNumber = account;
        balance = initial;
    }

    //---------------------------------------------------------------------
    //  Sets up the account by defining its owner, account number
    //----------------------------------------------------------------------
    public Account1(String owner,long account)
    {
        name = owner;
	acctNumber = account;
	balance = 0;
    }

    //----------------------------------------------------------------------
    //  Deposits the specified amount into the account. Returns the
    //  new balance.
    //----------------------------------------------------------------------
    public double deposit(double amount)
    {
        balance = balance + amount;
        return balance;
    }

    //----------------------------------------------------------------------
    //  Withdraws the specified amount from the account and applies
    //  the fee. Returns the new balance.
    //----------------------------------------------------------------------
    public double withdraw(double amount,double fee)
    {
        balance = balance - amount - fee;
        return balance;
    }

    //----------------------------------------------------------------------
    //  Adds interest to the account and returns the new balance.
    //----------------------------------------------------------------------
    public double addInterest()
    {
        balance += (balance * RATE);
        return balance;
    }

    //----------------------------------------------------------------------
    //  Returns the current balance of the account.
    //----------------------------------------------------------------------
    public double getBalance()
    {
        return balance;
    }

    //----------------------------------------------------------------------
    //  Reyurns a one-line description of the account as a string.
    //----------------------------------------------------------------------
    public String toString()
    {
        NumberFormat fmt = NumberFormat.getCurrencyInstance();
        return acctNumber + "\t" + name + "\t" + fmt.format(balance);
    }
}

